#include "textbutton.h"

TextButton::TextButton(QWidget *parent, QString btnText, QString textColor, QString mouseoverTextColor) :
    QLabel(parent),
    text(btnText),
    color(textColor),
    mouseoverColor(mouseoverTextColor)
{
    entered = false;
    updateText();
}

void TextButton::updateText()
{
    if(entered == false)
        setText("<font color='" + color + "'>" + text + "</font>");
    else
        setText("<font color='" + mouseoverColor + "'>" + text + "</font>");
}

void TextButton::setButtonText(QString newText)
{
    text = newText;
    updateText();
}

void TextButton::setTextColor(QString newColor)
{
    color = newColor;
    updateText();
}

void TextButton::setMouseoverColor(QString newColor)
{
    mouseoverColor = newColor;
}

void TextButton::mousePressEvent(QMouseEvent *ev)
{
    emit(clicked(ev));
}

void TextButton::enterEvent(QEvent *ev)
{
    entered = true;
    updateText();
}

void TextButton::leaveEvent(QEvent *ev)
{
    entered = false;
    updateText();
}
